3be068
@@ -807,6 +807,8 @@
public class HBaseFsck extends Configured implements Tool {
       }
     }
 
+    Path hbaseRoot = FSUtils.getRootDir(getConf());
+    FileSystem fs = hbaseRoot.getFileSystem(getConf());
     // serialized table info gathering.
     for (HbckInfo hbi: hbckInfos) {
 
@@ -828,12 +830,10 @@
public class HBaseFsck extends Configured implements Tool {
       if (modTInfo == null) {
         // only executed once per table.
         modTInfo = new TableInfo(tableName);
-        Path hbaseRoot = FSUtils.getRootDir(getConf());
         tablesInfo.put(tableName, modTInfo);
         try {
           HTableDescriptor htd =
-              FSTableDescriptors.getTableDescriptorFromFs(hbaseRoot.getFileSystem(getConf()),
-              hbaseRoot, tableName);
+              FSTableDescriptors.getTableDescriptorFromFs(fs, hbaseRoot, tableName);
           modTInfo.htds.add(htd);
         } catch (IOException ioe) {
           if (!orphanTableDirs.containsKey(tableName)) {
@@ -851,6 +851,8 @@
public class HBaseFsck extends Configured implements Tool {
       }
     }
 
+    loadTableInfosForTablesWithNoRegion();
+
     return tablesInfo;
   }
 
@@ -1849,6 +1851,8 @@
public class HBaseFsck extends Configured implements Tool {
       tablesInfo.put(tableName, modTInfo);
     }
 
+    loadTableInfosForTablesWithNoRegion();
+
     for (TableInfo tInfo : tablesInfo.values()) {
       TableIntegrityErrorHandler handler = tInfo.new IntegrityFixSuggester(tInfo, errors);
       if (!tInfo.checkRegionChain(handler)) {
@@ -1858,6 +1862,21 @@
public class HBaseFsck extends Configured implements Tool {
     return tablesInfo;
   }
 
+  /** Loads table info's for tables that may not have been included, since there are no
+   * regions reported for the table, but table dir is there in hdfs
+   */
+  private void loadTableInfosForTablesWithNoRegion() throws IOException {
+    Map<String, HTableDescriptor> allTables = new FSTableDescriptors(getConf()).getAll();
+    for (HTableDescriptor htd : allTables.values()) {
+      TableName tableName = htd.getTableName();
+      if (isTableIncluded(tableName) && !tablesInfo.containsKey(tableName)) {
+        TableInfo tableInfo = new TableInfo(tableName);
+        tableInfo.htds.add(htd);
+        tablesInfo.put(htd.getTableName(), tableInfo);
+      }
+    }
+  }
+
   /**
    * Merge hdfs data by moving from contained HbckInfo into targetRegionDir.
    * @return number of file move fixes done to merge regions.
@@ -2085,6 +2104,7 @@
public class HBaseFsck extends Configured implements Tool {
        * missing from META, HBase doesn't acknowledge the existance of the
        * table.
        */
+      @Override
       public void handleRegionStartKeyNotEmpty(HbckInfo next) throws IOException {
         errors.reportError(ERROR_CODE.FIRST_REGION_STARTKEY_NOT_EMPTY,
             "First region should start with an empty key.  Creating a new " +
@@ -2102,6 +2122,7 @@
public class HBaseFsck extends Configured implements Tool {
         fixes++;
       }
 
+      @Override
       public void handleRegionEndKeyNotEmpty(byte[] curEndKey) throws IOException {
         errors.reportError(ERROR_CODE.LAST_REGION_ENDKEY_NOT_EMPTY,
             "Last region should end with an empty key.  Creating a new "
@@ -2121,6 +2142,7 @@
public class HBaseFsck extends Configured implements Tool {
        * There is a hole in the hdfs regions that violates the table integrity
        * rules.  Create a new empty region that patches the hole.
        */
+      @Override
       public void handleHoleInRegionChain(byte[] holeStartKey, byte[] holeStopKey) throws IOException {
         errors.reportError(
             ERROR_CODE.HOLE_IN_REGION_CHAIN,
@@ -2305,6 +2327,12 @@
public class HBaseFsck extends Configured implements Tool {
 
       byte[] prevKey = null;
       byte[] problemKey = null;
+
+      if (splits.size() == 0) {
+        // no region for this table
+        handler.handleHoleInRegionChain(HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW);
+      }
+
       for (byte[] key : splits) {
         Collection<HbckInfo> ranges = regions.get(key);
         if (prevKey == null && !Bytes.equals(key, HConstants.EMPTY_BYTE_ARRAY)) {
@@ -2462,7 +2490,7 @@
public class HBaseFsck extends Configured implements Tool {
    * @return tables that have not been modified recently
    * @throws IOException if an error is encountered
    */
-   HTableDescriptor[] getTables(AtomicInteger numSkipped) {
+  HTableDescriptor[] getTables(AtomicInteger numSkipped) {
     List<TableName> tableNames = new ArrayList<TableName>();
     long now = System.currentTimeMillis();
 
@@ -2482,18 +2510,17 @@
public class HBaseFsck extends Configured implements Tool {
     return getHTableDescriptors(tableNames);
   }
 
-   HTableDescriptor[] getHTableDescriptors(List<TableName> tableNames) {
+  HTableDescriptor[] getHTableDescriptors(List<TableName> tableNames) {
     HTableDescriptor[] htd = new HTableDescriptor[0];
-     try {
-       LOG.info("getHTableDescriptors == tableNames => " + tableNames);
-       htd = new HBaseAdmin(getConf()).getTableDescriptorsByTableName(tableNames);
-     } catch (IOException e) {
-       LOG.debug("Exception getting table descriptors", e);
-     }
-     return htd;
+    try {
+      LOG.info("getHTableDescriptors == tableNames => " + tableNames);
+      htd = new HBaseAdmin(getConf()).getTableDescriptorsByTableName(tableNames);
+    } catch (IOException e) {
+      LOG.debug("Exception getting table descriptors", e);
+    }
+    return htd;
   }
 
-
   /**
    * Gets the entry in regionInfo corresponding to the the given encoded
    * region name. If the region has not been seen yet, a new entry is added
@@ -2575,11 +2602,13 @@
public class HBaseFsck extends Configured implements Tool {
 
       // comparator to sort KeyValues with latest modtime
       final Comparator<Cell> comp = new Comparator<Cell>() {
+        @Override
         public int compare(Cell k1, Cell k2) {
           return (int)(k1.getTimestamp() - k2.getTimestamp());
         }
       };
 
+      @Override
       public boolean processRow(Result result) throws IOException {
         try {
 
@@ -2654,6 +2683,7 @@
public class HBaseFsck extends Configured implements Tool {
       this.splitB = splitB;
     }
 
+    @Override
     public boolean equals(Object o) {
       boolean superEq = super.equals(o);
       if (!superEq) {
@@ -2701,6 +2731,7 @@
public class HBaseFsck extends Configured implements Tool {
     HRegionInfo hri;
     ServerName hsa;
 
+    @Override
     public String toString() {
       return hsa.toString() + ";" + hri.getRegionNameAsString();
     }
@@ -2729,6 +2760,7 @@
public class HBaseFsck extends Configured implements Tool {
       this.deployedOn.add(server);
     }
 
+    @Override
     public synchronized String toString() {
       StringBuilder sb = new StringBuilder();
       sb.append("{ meta => ");
@@ -2960,12 +2992,14 @@
public class HBaseFsck extends Configured implements Tool {
     // for use by unit tests to verify which errors were discovered
     private ArrayList<ERROR_CODE> errorList = new ArrayList<ERROR_CODE>();
 
+    @Override
     public void clear() {
       errorTables.clear();
       errorList.clear();
       errorCount = 0;
     }
 
+    @Override
     public synchronized void reportError(ERROR_CODE errorCode, String message) {
       if (errorCode == ERROR_CODE.WRONG_USAGE) {
         System.err.println(message);
@@ -2980,11 +3014,13 @@
public class HBaseFsck extends Configured implements Tool {
       showProgress = 0;
     }
 
+    @Override
     public synchronized void reportError(ERROR_CODE errorCode, String message, TableInfo table) {
       errorTables.add(table);
       reportError(errorCode, message);
     }
 
+    @Override
     public synchronized void reportError(ERROR_CODE errorCode, String message, TableInfo table,
                                          HbckInfo info) {
       errorTables.add(table);
@@ -2992,6 +3028,7 @@
public class HBaseFsck extends Configured implements Tool {
       reportError(errorCode, reference + " " + message);
     }
 
+    @Override
     public synchronized void reportError(ERROR_CODE errorCode, String message, TableInfo table,
                                          HbckInfo info1, HbckInfo info2) {
       errorTables.add(table);
@@ -3000,6 +3037,7 @@
public class HBaseFsck extends Configured implements Tool {
       reportError(errorCode, reference + " " + message);
     }
 
+    @Override
     public synchronized void reportError(String message) {
       reportError(ERROR_CODE.UNKNOWN, message);
     }
@@ -3009,6 +3047,7 @@
public class HBaseFsck extends Configured implements Tool {
      * where the actual error would have been reported previously.
      * @param message
      */
+    @Override
     public synchronized void report(String message) {
       if (! summary) {
         System.out.println("ERROR: " + message);
@@ -3016,6 +3055,7 @@
public class HBaseFsck extends Configured implements Tool {
       showProgress = 0;
     }
 
+    @Override
     public synchronized int summarize() {
       System.out.println(Integer.toString(errorCount) +
                          " inconsistencies detected.");
@@ -3028,10 +3068,12 @@
public class HBaseFsck extends Configured implements Tool {
       }
     }
 
+    @Override
     public ArrayList<ERROR_CODE> getErrorList() {
       return errorList;
     }
 
+    @Override
     public synchronized void print(String message) {
       if (!summary) {
         System.out.println(message);
@@ -3048,6 +3090,7 @@
public class HBaseFsck extends Configured implements Tool {
       errorCount = 0;
     }
 
+    @Override
     public synchronized void detail(String message) {
       if (details) {
         System.out.println(message);
@@ -3055,6 +3098,7 @@
public class HBaseFsck extends Configured implements Tool {
       showProgress = 0;
     }
 
+    @Override
     public synchronized void progress() {
       if (showProgress++ == 10) {
         if (!summary) {
